

package com.hazelcast.security.impl.function;

import com.hazelcast.spi.annotation.PrivateApi;

import javax.annotation.Nullable;
import java.security.Permission;
import java.util.List;

/**
 * A function which requires some permissions to run, see {@link #permissions()}.
 * The default implementation returns {@code null} which means no
 * permission is required to run this function.
 *
 * @see SecuredFunctions
 */
@PrivateApi
public interface SecuredFunction {

    /**
     * @return the list of permissions required to run this function
     * @implNote If used, permissions should be hardcoded based on function arguments/context.
     * It is not secure to keep {@code List<Permission>} in the function itself because
     * it could be tampered with if the function is serialized and passed from untrusted caller.
     */
    @Nullable
    default List<Permission> permissions() {
        return null;
    }
}
